package com.tpod.taxi;

import tpod.network.http.HTTPRequestLoaderManager;
import tpod.utils.debug.Debug;
import android.app.Activity;
import android.app.Application;
import android.os.Bundle;

public abstract class TaxiActivity extends Activity {

	private TaxiApplication taxiApplication;
	protected boolean locationService = false;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Debug.debug(getClass().getSimpleName() + " on create activity");
		HTTPRequestLoaderManager.getRequestQueue().cancelAll();
		setTaxiApplication(getApplication());
	}

	@Override
	protected void onStart() {
		super.onStart();
		Debug.debug(getClass().getSimpleName() + " on start activity");
		getTaxiApplication().updateConnectionMode(getActivity());
	}

	@Override
	protected void onResume() {
		Debug.debug(getClass().getSimpleName() + " on resume activity");
		super.onResume();
	}

	@Override
	public void onBackPressed() {
		this.finish();
	}

	@Override
	public void onLowMemory() {
		super.onLowMemory();
		Debug.debug(getClass().getSimpleName() + " on LOW MEMORY");
		Debug.logHeap("on Low Memory");
		System.gc();
		Runtime.getRuntime().gc();
	}

	abstract protected Activity getActivity();

	public void setTaxiApplication(Application taxiApplication) {
		this.taxiApplication = (TaxiApplication) taxiApplication;
	}

	public TaxiApplication getTaxiApplication() {
		return taxiApplication;
	}

}
